home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / examples / dtksh / CallbackTest2.z / CallbackTest2
Encoding:
Text File  |  2003-11-18  |  3.4 KB  |  113 lines

  1. #! /usr/dt/bin/dtksh
  2. #
  3. # CallbackTest2
  4. #
  5. # Copyright 2000, Silicon Graphics, Inc.
  6. # ALL RIGHTS RESERVED
  7. # UNPUBLISHED -- Rights reserved under the copyright laws of the United
  8. # States.   Use of a copyright notice is precautionary only and does not
  9. # imply publication or disclosure.
  10. #
  11. # U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  12. # Use, duplication or disclosure by the Government is subject to restrictions
  13. # as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  14. # in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  15. # in similar or successor clauses in the FAR, or the DOD or NASA FAR
  16. # Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  17. # 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  18. #
  19. # THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  20. # INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  21. # DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  22. # PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  23. # GRAPHICS, INC.
  24. #
  25.  
  26. ##########################################################################
  27. #  (c) Copyright 1993, 1994 Hewlett-Packard Company    
  28. #  (c) Copyright 1993, 1994 International Business Machines Corp.
  29. #  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  30. #  (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  31. #      Novell, Inc.
  32. ##########################################################################
  33.  
  34.  
  35. #
  36. # This sample shell script demonstrates how widget callbacks can be
  37. # added and removed.  It adds callbacks both using XtAddCallback and
  38. # by specifying a callback as a resource, when the test pushbutton
  39. # is created.
  40. #
  41.  
  42. # The activate callback which can be dynamically added and removed
  43. ActivateCallback1()
  44. {
  45.    echo "activateCallback1 invoked"
  46. }
  47.  
  48. # The activate callback which is added when the widget was created
  49. ActivateCallback2()
  50. {
  51.    echo "activateCallback2 invoked"
  52. }
  53.  
  54. # Pushbutton Callback: Adds an activate callback to the test pushbutton
  55. AddCallback1()
  56. {
  57.    XtAddCallback $TESTPB activateCallback ActivateCallback1
  58.    XtGetValues $TESTPB activateCallback:AC
  59.    echo "Callback list = "$AC
  60. }
  61.  
  62. # Pushbutton Callback: Removes an activate callback from the test pushbutton
  63. DeleteCallback1()
  64. {
  65.    XtRemoveCallback $TESTPB activateCallback ActivateCallback1
  66.    XtGetValues $TESTPB activateCallback:AC2
  67.    echo "Callback list = "$AC2
  68. }
  69.  
  70. ######################### Create the Main UI #################################
  71.  
  72. XtInitialize TOPLEVEL callbackTest CallbackTest "$0" "$@"
  73.  
  74. XtCreateManagedWidget FORM form XmForm $TOPLEVEL
  75.  
  76. XtCreateManagedWidget PB1 pb XmPushButton $FORM \
  77.     labelString:"Add Callback1" \
  78.     topAttachment:ATTACH_FORM \
  79.     topOffset:10 \
  80.     leftAttachment:ATTACH_POSITION \
  81.     leftPosition:10 \
  82.     rightAttachment:ATTACH_POSITION \
  83.     rightPosition:40 \
  84.     activateCallback:AddCallback1
  85.  
  86. XtCreateManagedWidget PB2 pb2 XmPushButton $FORM \
  87.     labelString:"Delete Callback1" \
  88.     topAttachment:ATTACH_FORM \
  89.     topOffset:10 \
  90.     leftAttachment:ATTACH_POSITION \
  91.     leftPosition:60 \
  92.     rightAttachment:ATTACH_POSITION \
  93.     rightPosition:90 \
  94.     activateCallback:DeleteCallback1
  95.  
  96. XtCreateManagedWidget TESTPB testpb XmPushButton $FORM \
  97.     labelString:"Test Button" \
  98.     topAttachment:ATTACH_WIDGET \
  99.     topWidget:$PB2 \
  100.     topOffset:20 \
  101.     leftAttachment:ATTACH_POSITION \
  102.     leftPosition:20 \
  103.     rightAttachment:ATTACH_POSITION \
  104.     rightPosition:80 \
  105.     bottomAttachment:ATTACH_FORM \
  106.     bottomOffset:10 \
  107.     activateCallback:ActivateCallback2
  108.  
  109. XtRealizeWidget $TOPLEVEL
  110.  
  111. XtMainLoop
  112.